package im.yisme.view.activities;

/**
 * 游戏打开显示spalsh的activity
 * @author jwj  2013/2/2
 */

import im.yisme.R;
import im.yisme.model.service.LyricsRepositoryService;
import im.yisme.model.service.ModelServiceProvider;
import im.yisme.model.service.MusicRepositoryService;
import im.yisme.view.service.ViewService;
import im.yisme.view.service.ViewServiceProvider;
import im.yisme.view.ui.animation.BGP;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

public class SplashActivity extends Activity {

	private ViewService viewCtrl;
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_splash);
		
		viewCtrl=ViewServiceProvider.getViewService();
		
		load();
		new Handler().postDelayed(new Runnable() {
			public void run() {
				jumpToMainActivity();
			}
		}, 2000);
	}

	private void load() {
		MusicRepositoryService service = ModelServiceProvider
				.getMusicRepositoryService();
		service.loadFile();

		LyricsRepositoryService lyricsRepositoryService = ModelServiceProvider
				.getLyricsRepositoryService();
		lyricsRepositoryService.loadFile();
	}

	private void jumpToMainActivity() {
		Intent intent = new Intent(SplashActivity.this, MainActivity.class);
		viewCtrl.jumpTo(intent);
	}
	
	protected void onResume(){
		super.onResume();
		viewCtrl.updateTopActivity(this); 
	}
	
	protected void onStop(){
		super.onStop();
		finish();
	}
}
